package andev.schoolhelper.main;

import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import andev.schoolhelper.R;

public class MSGFragment extends Fragment {
    private LinearLayout root;
    private ImageView actionbar_menu;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        root = (LinearLayout) inflater.inflate(R.layout.fragment_msg, container, false);
        InitActionBar();
        return root;
    }

    private void InitActionBar() {
        MainActivity mainActivity = (MainActivity) this.getActivity();
        mainActivity.actionbarLayout.removeView(mainActivity.getActionbar_middle_tv());

        actionbar_menu = mainActivity.getActionbar_menu();
        actionbar_menu.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        actionbar_menu.setBackgroundColor(Color.parseColor("#80d4d6d9"));
                        break;
                    case MotionEvent.ACTION_UP:
                        v.performClick();
                        actionbar_menu.setBackgroundColor(Color.TRANSPARENT);
                        break;
                    default:
                        break;
                }
                return false;
            }
        });
    }
}
